/*
 * Copyright 2007-2008 Michele Mostarda ( michele.mostarda@gmail.com ).
 * All Rights Reserved.
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package org.michelemostarda;

import java.util.HashMap;
import java.util.Map;

/**
 * Contains the attributes of a Wiki page.
 */
public class PageAttributes {

    /**
     * Title key.
     */
    public static final String TITLE = "title";

    /**
     * Author key.
     */
    public static final String AUTHOR = "author";

    /**
     * The attributes map.
     */
    private Map<String,String> attributes;

    /**
     * Constructor.
     */
    public PageAttributes() {
        attributes = new HashMap<String,String>();
    }

    /**
     * Constructor.
     *
     * @param title the page title.
     */
    public PageAttributes(String title) {
        this();
        attributes.put(TITLE, title);
    }

    /**
     * Constructor.
     *
     * @param title the page title.
     */
    public PageAttributes(String title, String author) {
        this();
        attributes.put(TITLE, title);
        attributes.put(AUTHOR, author);
    }

    /**
     * Returns the page title.
     * @return
     */
    public String getTitle() {
        return attributes.get(TITLE);
    }

    /**
     * Returns the page author.
     * @return
     */
    public String getAuthor() {
        return attributes.get(AUTHOR);
    }

    /**
     * Returns an attribute by name, <code>null</code> if undefined.
     * @param name
     * @return
     */
    public String getAttribute(String name) {
        return attributes.get(name);
    }

    /**
     * Sets an attribute.
     * 
     * @param name
     * @param value
     */
    public void setAttribute(String name, String value) {
        attributes.put(name, value);
    }

}
